package com.javapda.c328r.command.impl;

import org.apache.commons.lang.builder.ToStringBuilder;

import com.javapda.util.ByteUtil;


/**
 * 
 * 
 */
public class DataComediaCommand extends AbstractComediaCommand {
	private transient String toString;

	public String toString() {
		if (toString == null) {
			toString = new ToStringBuilder(this)
							.append("Data Type", getDataType())
							.append("Image Size", getImageSize())
							.append("Image Size Low Byte", getImageSizeLowByte() + "|" + Integer.toHexString(getImageSizeLowByte()))
							.append("Image Size Medium Byte", getImageSizeMediumByte() + "|" + Integer.toHexString(getImageSizeMediumByte()))
							.append("Image Size High Byte", getImageSizeHighByte() + "|" + Integer.toHexString(getImageSizeHighByte()))
							.append("Image Size HEX", getImageSizeHex())
							.toString();
		}
		return toString;
	}
	public int getImageSize() {
		int[] nums = new int[3];
		nums[0] = getImageSizeLowByte();
		nums[1] = getImageSizeMediumByte();
		nums[2] = getImageSizeHighByte();
		int imageSize = ByteUtil.intArrayToInt(nums);
		return imageSize;
	}
	private String getImageSizeHex() {
		StringBuilder sb = new StringBuilder();
		sb.append(Integer.toHexString(getImageSizeHighByte()));
		sb.append(Integer.toHexString(getImageSizeMediumByte()));
		sb.append(Integer.toHexString(getImageSizeLowByte()));
		return sb.toString();
	}
	public void setImageSizeLowByte(int imageSizeHighByte) {
		setParameter2(imageSizeHighByte);
	}
	public int getImageSizeLowByte() {
		return getParameter2();
	}
	public void setImageSizeMediumByte(int imageSizeHighByte) {
		setParameter3(imageSizeHighByte);
	}
	public int getImageSizeMediumByte() {
		return getParameter3();
	}
	public void setImageSizeHighByte(int imageSizeHighByte) {
		setParameter4(imageSizeHighByte);
	}
	public int getImageSizeHighByte() {
		return getParameter4();
	}
	public DataComediaCommand() {
		super(new DataComediaCommandId());
	}
	public DataComediaCommand(int[] dataInfo) {
		this();
		setDataType(dataInfo[2]);
		setImageSizeLowByte(dataInfo[3]);
		setImageSizeMediumByte(dataInfo[4]);
		setImageSizeHighByte(dataInfo[5]);
	}
	public void setDataType(int pictureType) {
		setParameter1(pictureType);
	}
	public int getDataType() {
		return getParameter1();
	}

}
